{template 'common/header'}
<style>
    .we7-table  td, .we7-table  th {border:1px solid #e6e6e6 !important;vertical-align:middle !important;}
</style>
<ul class="we7-page-tab">
    <li class="active">
        <a href="javacript:void(0)">应用管理</a>
    </li>
</ul>
<div class="clearfix">
    <table class="table we7-table table-hover">
        <thead class="navbar-inner">
        <tr>
            <th class="text-center"  colspan="3">本地应用</th>
        </tr>
        <tr>
            <th class="text-center" style="width:100px;">应用名称</th>
            <th class="text-center" style="width:150px">更新时间</th>
            <th class="text-center" style="width:100px;">操作</th>
        </tr>
        </thead>
        <tbody>
        {loop $data $key $item}
        <tr>
            <td class="text-center" valign="middle">{$item['title']}</td>
            <td class="text-center" valign="middle">
                {if $item['isupdate']==1}
                    本地：{php echo date('Y-m-d H:i:s', $item['local_update_time'])}<br/>
                    服务器：{php echo date('Y-m-d H:i:s', $item['update_time'])}
                {else}
                    {php echo date('Y-m-d H:i:s', $item['update_time'])}
                {/if}

            </td>
            <td class="text-center" valign="middle">
                {if $item['isupdate']==1}<a class="ajax-action" href="javacript:void(0)" data-submit="1" data-message="正在更新，请等待" data-sussesmessge="更新成功" data-href="{url 'site/entry/dashboard_setup' array('m'=>'diygwcom_app', 'pid'=>$item['id'])}" >更新</a>{/if}
                {if $item['isnew']==1}<a class="ajax-action" href="javacript:void(0)" data-submit="1" data-message="正在安装，请等待" data-sussesmessge="安装成功"  data-href="{url 'site/entry/dashboard_setup' array('m'=>'diygwcom_app', 'pid'=>$item['id'])}" >安装</a>{/if}
                {if $item['ismanage']==1}
                    <a  href="{url 'site/entry/admin_index' array('m'=>'diygwcom_app', 'pid'=>$item['id'],'template'=>'mobile')}" >前台展示</a>
                    <a  href="{url 'site/entry/admin_index' array('m'=>'diygwcom_app', 'pid'=>$item['id'],'template'=>'web')}" >后台管理</a>
                    <a  href="{url 'site/entry/dashboard_delete' array('m'=>'diygwcom_app', 'pid'=>$item['id'],'template'=>'web')}" >删除应用</a>
                {/if}
            </td>
        </tr>
        {/loop}
        </tbody>
    </table>
    {if !empty($remotedata)}
    <table class="table we7-table table-hover">
        <thead class="navbar-inner">
        <tr>
            <th class="text-center"  colspan="3">远程应用</th>
        </tr>
        <tr>
            <th class="text-center" style="width:100px;">应用名称</th>
            <th class="text-center" style="width:150px">更新时间</th>
            <th class="text-center" style="width:100px;">操作</th>
        </tr>
        </thead>
        <tbody>
        {loop $remotedata $key $item}
        <tr>
            <td class="text-center" valign="middle">{$item['title']}</td>
            <td class="text-center" valign="middle">
                {php echo date('Y-m-d H:i:s', $item['update_time'])}
            </td>
            <td class="text-center" valign="middle">
                <a class="ajax-action" href="javacript:void(0)" data-submit="1" data-message="正在安装，请等待" data-sussesmessge="安装成功"  data-href="{url 'site/entry/dashboard_setup' array('m'=>'diygwcom_app', 'pid'=>$item['id'])}" >安装</a>
            </td>
        </tr>
        {/loop}
        </tbody>
    </table>
    {/if}
    <div>如果还没有应用，请点击<a href="http://www.diygw.com" target="_blank" style="color: #ff0000;">DIY官网http://www.diygw.com设计</a></div>
</div>
<script>

    $(".ajax-action").click(function(){
        if($(this).data("submit")=="1"){
            var thiz = $(this);
            thiz.data("submit","0");
            util.loading(thiz.data('message'));
            $.post(thiz.data('href'), function (res) {
                if (res.type == 'error') {
                    util.message(thiz.data('sussesmessge'), '', 'error');
                } else {
                    util.message(thiz.data('sussesmessge'), location.href, 'success');
                }
                thiz.data("submit","0");
            }, 'json').error(function (error) {
                thiz.data("submit","0");
                util.message('保存出错,请重试', '', 'error');
            })
        }
        return false;
    })
</script>
{template 'common/footer'}